home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / wot-20080519-fx.xpi / chrome / wot.jar / content / storage.js < prev    next >
Text File  |  2007-11-11  |  1KB  |  68 lines

  1. /*
  2.     storage.js
  3.  
  4.     Copyright ┬⌐ 2006, 2007  Against Intuition, Inc. <info@mywot.com>
  5. */
  6.  
  7. var wot_hashtable =
  8. {
  9.     init: function()
  10.     {
  11.         try {
  12.             if (this.bag) {
  13.                 return;
  14.             }
  15.             this.bag = Components.classes["@mozilla.org/hash-property-bag;1"].
  16.                         getService(Components.interfaces.nsIWritablePropertyBag);
  17.         } catch (e) {
  18.             dump("wot_hashtable.init: failed with: " + e + "\n");
  19.         }
  20.  
  21.         window.addEventListener("unload", function(e) {
  22.                 wot_hashtable.unload(); }, false);
  23.     },
  24.  
  25.     unload: function()
  26.     {
  27.         this.bag = null;
  28.     },
  29.  
  30.     set: function(name, value)
  31.     {
  32.         try {
  33.             this.bag.setProperty(name, value);
  34.         } catch (e) {
  35.             dump("wot_hashtable.set: failed with " + e + "\n");
  36.         }
  37.     },
  38.  
  39.     get: function(name)
  40.     {
  41.         try {
  42.             return this.bag.getProperty(name);
  43.         } catch (e) {
  44.         }
  45.         return null;
  46.     },
  47.  
  48.     remove: function(name)
  49.     {
  50.         try {
  51.             this.bag.deleteProperty(name);
  52.         } catch (e) {
  53.         }
  54.     },
  55.  
  56.     get_enumerator: function(name)
  57.     {
  58.         try {
  59.             return this.bag.enumerator;
  60.         } catch (e) {
  61.             dump("wot_hashtable.get_enumerator: failed with " + e + "\n");
  62.         }
  63.         return null;
  64.     }
  65. };
  66.  
  67. wot_hashtable.init();
  68.